package com.ruoyi.paip.domain.paip;

import lombok.Data;

import java.io.Serializable;

/**
 * 接口响应顶层结构
 */
@Data
public class Response<T> implements Serializable {
    private Integer code;
    private Result<T> result;

    public boolean isSuccess() {
        return code == 0;
    }

    public T getData() {
        if (isSuccess()) {
            Result<T> result = this.getResult();
            if (result.getSuccess()) {
                return result.getData();
            } else {
                throw new RuntimeException(result.getMsg());
            }
        }
        return null;
    }
}
